package proto

import "core/entity"

type RoomCreator struct {
	Uid         string      `json:"uid"`
	CreatorType CreatorType `json:"creatorType"`
}

type CreatorType int

const (
	UserCreatorType  CreatorType = 1
	UnionCreatorType             = 2
)

type RoomUserInfo struct {
	UserInfo   *UserInfo  `json:"userInfo"`
	ChairId    int        `json:"chairID"`
	UserStatus UserStatus `json:"userStatus"`
}

type UserInfo struct {
	Uid          string `json:"uid"`
	Nickname     string `json:"nickname"`
	Avatar       string `json:"avatar"`
	Gold         int64  `json:"gold"`
	FrontendId   string `json:"frontendId"`
	Address      string `json:"address"`
	Location     string `json:"location"`
	LastLoginIP  string `json:"lastLoginIP"`
	Sex          int    `json:"sex"`
	Score        int    `json:"score"`
	SpreaderID   string `json:"spreaderID"` //推广ID
	ProhibitGame bool   `json:"prohibitGame"`
	RoomID       string `json:"roomID"`
}

type UserStatus int

const (
	None    UserStatus = 0
	Ready              = 1
	Playing            = 2
	Offline            = 4
	Dismiss            = 8
)

func ToRoomUserInfo(data *entity.User, chairId int) *RoomUserInfo {
	userInfo := &UserInfo{
		Uid:        data.Uid,
		Nickname:   data.Nickname,
		Avatar:     data.Avatar,
		Location:   data.Location,
		Gold:       data.Gold,
		FrontendId: data.FrontendId,
		Address:    data.Address,
		Sex:        data.Sex,
	}
	return &RoomUserInfo{
		UserInfo:   userInfo,
		ChairId:    chairId,
		UserStatus: None,
	}
}
